from selenium import webdriver
from selenium.webdriver.common.by import By
import time

url = 'http://jn.58.com'
driver = webdriver.Edge()
driver.get(url)

print(driver.current_url)
print(driver.window_handles)
# 点击租房按钮
el = driver.find_element(By.XPATH, '/html/body/div[3]/div[1]/div[1]/div/div[1]/div[1]/span[2]/a')
# 点击，但操作权未转移到新页面
el.click()
time.sleep(10)

print(driver.current_url)
print(driver.window_handles)
# 通过句柄切换页面
driver.switch_to.window(driver.window_handles[-1])
el_list = driver.find_elements(By.XPATH, '/html/body/div[6]/div[2]/ul/li/div[2]/h2/a')
print(len(el_list))
driver.close()